home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: makholm@diku.dk (Henning Makholm)
- Newsgroups: comp.lang.c,comp.lang.c.moderated
- Subject: Re: C coding problem
- Date: 19 Mar 1996 06:46:28 -0600
- Organization: Department of Computer Science, U of Copenhagen
- Sender: clc@solutions.solon.com
- Approved: clc@solutions.solon.com
- Message-ID: <4imab4$dt9@solutions.solon.com>
- References: <4ianbf$h86@solutions.solon.com>
- NNTP-Posting-Host: solutions.solon.com
-
- proctor@corp.hp.com (Stephen Proctor) writes:
-
- >I am trying to write a *simple* C program and am running into the following
- >warning problem shown below. Why do I get this warning?
-
- > if (*argv[ii] == '-') option_val = read_options;
-
- I'd guess that you've programmed in Pascal before and made a function
- of no parameters calles read_options. However, in C you always need
- parentheses to express a function call, even when there are no
- parameters. What you probably mean is,
-
- if ( ....... ) option_val = read_options();
-
-
- In C, (almost) any mention of a function identifier formally produces
- a value which is a pointer to a function (and the right argument to
- the function-call parentheses is likewise expected to be a pointer to
- a function). Since you do not - to the compiler - appear to call your
- function pointer, it complains then you try to assign that pointer to
- an integer variable, hence the fluff about integer/pointer problems in
- the warning.
-
- (More than a few of the others who responded had this in mind, I
- think. Why didn't anybody explain this, then? There is this strange
- urge to make oneself stupider than one is when trying to help some
- poor newbie, it be with C or almost any other topic. Why, the general
- attitude ought to be "maybe your problem is this-and-this", rather
- than assume I am a machine and complain about missing information
- with THE canonical C newbie problem blinking there right in my
- face. Sure, I don't claim to be better than others, and I often find
- myself falling into that trap in my work as an instructor. I was
- about to do the same again here but felt sorry for the guy...)
-
- [hp newsgrous removed from newsgroups line as this is a general C problem]
-
- --
-
- Henning Makholm - math and CS student - University of Copenhagen
- makholm@diku.dk - http://www.diku.dk/students/makholm - fido 2:235/224.92
-